#include "dynamic_json_ui/widget_registry.h"

namespace dynamic_json_ui {

WidgetRegistry &WidgetRegistry::instance()
{
    static WidgetRegistry inst;
    return inst;
}

void WidgetRegistry::registerWidget(const QString &id, QWidget *widget)
{
    if (widget && !id.isEmpty()) {
        registry[id] = widget;
    }
}

QWidget *WidgetRegistry::getWidget(const QString &id)
{
    if (registry.contains(id)) {
        return registry.value(id);
    }
    return nullptr;
}

} // namespace dynamic_json_ui
